#ifndef Base64Util_h
#define Base64Util_h

#define ATL_BASE64_FLAG_NONE	0
#define ATL_BASE64_FLAG_NOPAD	1
#define ATL_BASE64_FLAG_NOCRLF  2

bool IsBase64Char(unsigned char ch);

int Base64EncodeGetRequiredLength(int nSrcLen, unsigned long dwFlags = ATL_BASE64_FLAG_NONE);

int Base64DecodeGetRequiredLength(int nSrcLen);

bool Base64Encode(const unsigned char* pbSrcData,
                  int                  nSrcLen,
                  char*                szDest,
                  int*                 pnDestLen,
                  unsigned long        dwFlags = ATL_BASE64_FLAG_NONE);

bool Base64Decode(const char*    szSrc,
                  int            nSrcLen,
                  unsigned char* pbDest,
                  int*           pnDestLen);

HRESULT Base64EncodeEx(BYTE*  pbyData,
                       DWORD  dwSize,
                       CHAR** ppszBase64Str,
                       DWORD* pdwBase64Len = NULL,
                       DWORD  dwFlags = ATL_BASE64_FLAG_NONE);

HRESULT Base64DecodeEx(CCHAR* szBase64Str,
                       BYTE** ppbyDecodedData,
                       DWORD* pdwDecodedSize);


#endif // Base64Util_h
